#!/bin/bash

# invocazioni non valide
# opzione -a  non permessa
echo Test1
if ./bristat -a -p ; then
    exit 1
fi

# opzione -p  ripetuta
echo Test2
if ./bristat -p -u ciccio -p BRS-1.log ; then
    exit 1
fi

# mancano i file da elaborare
echo Test3
if ./bristat -m ; then
    exit 1
fi

# -u senza parametro
echo Test4
if ./bristat -m BRS-1.log -u; then
    exit 1
fi

# file non esistente non ci sono file da elaborare
echo Test5
if ./bristat  -p __ciccio -u gigi; then
    exit 1
fi

# file esistente
# non contiene l'utente ciccio
echo TestB1
if ! ./bristat -u ciccio BRS-1.log ; then
    exit 1
fi
if ! ./bristat -u ciccio BRS-1.log -m -p; then
    exit 1
fi

# file esistente tutti gli utenti presenti devono essere elaborati
echo TestB2
if ! ./bristat BRS-1.log -m ; then
    exit 1
fi

# piu file esistente tutti gli utentipresenti  devono essere elaborati
echo TestB3
if ! ./bristat BRS-1.log BRS-33367.log BRS-2.log -p -m BRS-2.log BRS-333.log BRS-43.log BRS-44.log; then
 exit 1
fi

# piu file esistente tutti gli utentipresenti  devono essere elaborati
echo TestB4
if ! ./bristat -m BRS-1.log BRS-33367.log BRS-2.log  BRS-2.log BRS-333.log BRS-43.log BRS-44.log; then
 exit 1
fi


# piu file esistenti un solo utente superpippo
echo TestB5
if ! ./bristat BRS-333.log BRS-43.log -u superpippo; then
 exit 1
fi


# piu file esistenti un solo utente topolino
echo TestB6
if ! ./bristat BRS-1.log -p BRS-33367.log -m BRS-2.log  BRS-2.log BRS-333.log BRS-43.log BRS-44.log -u topolino;  then
 exit 1
fi
exit 0

